package chuangya.com.anmi;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.Window;
import android.view.WindowManager;
import android.widget.FrameLayout;

import com.example.administrator.sunstart_library.BaseActivity;

import java.util.ArrayList;
import java.util.List;

import butterknife.ButterKnife;
import butterknife.InjectView;
import chuangya.com.anmi.adapter.MainBottomAdapter;
import chuangya.com.anmi.databean.MainBottomData;
import chuangya.com.anmi.fragment.BookCaseFragment;
import chuangya.com.anmi.fragment.BookFragment;
import chuangya.com.anmi.fragment.MainFragment;
import chuangya.com.anmi.fragment.MineFragment;

import static android.view.View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;

public class MainActivity extends BaseActivity {

    @InjectView(R.id.mainactivity_body)
    FrameLayout mainactivityBody;
    @InjectView(R.id.mainactivity_ottom)
    RecyclerView mainactivityOttom;
    private List<Fragment> fragmentList = new ArrayList<>();
    private List<MainBottomData> bottomDataList = new ArrayList<>();
    private MainBottomAdapter adapter;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ButterKnife.inject(this);
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        SetStatusBarColor(R.color.textBrightGray);
        fragmentList.add(new MainFragment());
        fragmentList.add(new BookFragment());
        fragmentList.add(new BookCaseFragment());
        fragmentList.add(new MineFragment());
        initBottom();
        initFragment();
    }

    private void initFragment() {
        getSupportFragmentManager().beginTransaction().add(R.id.mainactivity_body,fragmentList.get(0)).show(fragmentList.get(0)).commit();
    }

    private void initBottom() {
        MainBottomData main = new MainBottomData(R.mipmap.main_icon, R.mipmap.main_icon_gray, "漫画");
        main.setCheck(true);
        bottomDataList.add(main);
        bottomDataList.add(new MainBottomData(R.mipmap.main_book,R.mipmap.main_book_gray,"文章"));
        bottomDataList.add(new MainBottomData(R.mipmap.main_bookcase,R.mipmap.main_bookcase_gray,"书架"));
        bottomDataList.add(new MainBottomData(R.mipmap.main_mine,R.mipmap.main_mine_gray,"我的"));
        adapter = new MainBottomAdapter(this,bottomDataList);
        GridLayoutManager manager = new GridLayoutManager(this,4);
        mainactivityOttom.setAdapter(adapter);
        mainactivityOttom.setLayoutManager(manager);
    }

    @Override
    public int setBaseView() {
        return R.layout.activity_main;
    }

    @Override
    public boolean showTitle() {
        return false;
    }

    @Override
    public String setTitleText() {
        return null;
    }

    @Override
    public boolean showMore() {
        return false;
    }

}
